//
// Created by user on 2022/3/1.
//
#include <vector>
#include <stack>
using namespace std;
bool validateStackSequences(vector<int>& pushed, vector<int>& popped) {
    stack<int> st1;

    int i = 0;
    for(int p : pushed){
        st1.push(p);
        while (!st1.empty() && i<popped.size() && popped[i]==st1.top()){
            st1.pop();
            i++;
        }
    }
    return i==popped.size();
}